﻿using System.Reflection;

namespace CodeBackup.FrmGrid
{
    internal class GridFactory
    {

        public static IGrid GetGrid(string frmName)
        {
            Type type = Type.GetType($"{MethodBase.GetCurrentMethod().DeclaringType.Namespace}.{frmName}Grid");
            return (IGrid)Activator.CreateInstance(type); ;
        }

        /// <summary>
        /// 多類型窗體
        /// </summary>
        /// <param name="frmName"></param>
        /// <param name="args"></param>
        /// <returns></returns>
        public static IGrid GetGrid(string frmName, object[] args)
        {
            Type type = Type.GetType($"{MethodBase.GetCurrentMethod().DeclaringType.Namespace}.{frmName}Grid");
            return (IGrid)Activator.CreateInstance(type, args);
        }
    }
}
